//db模块的封装
// 导入mysql
const mysql = require('mysql')

// 创建连接对象
const connect = mysql.createConnection({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'root',
    database: 'mydb'
})

exports.query = function(sql, params, callback) {
    connect.connect()
    connect.query(sql, params, (err, data) => {
        callback &&  callback(err, data)
    })
    connect.end()
}
